package com.github.aloxc.plugin.restplus.i18n;


import org.jetbrains.annotations.NotNull;

import java.io.IOException;
import java.io.InputStream;
import java.util.*;
/**
 *
 * @author leero
 */
public class XmlResourceBundle
        extends ResourceBundle
{
    private Properties props;

    XmlResourceBundle(InputStream stream) throws IOException {
        this.props = new Properties();
        this.props.loadFromXML(stream);
    }



    @Override
    protected Object handleGetObject(String key) { return this.props.getProperty(key); }



    @Override
    @NotNull
    public Enumeration<String> getKeys() {
        List<String> keys = new ArrayList<>();
        Enumeration<Object> enumeration = this.props.keys();
        while (enumeration.hasMoreElements()) {
            keys.add((String)enumeration.nextElement());
        }
        return Collections.enumeration(keys);
    }
}
